package cn.hrlly.tao2shou.biz;

import android.content.Context;
import android.widget.Toast;

import cn.hrlly.tao2shou.R;
import cn.hrlly.tao2shou.domain.User;
import cn.hrlly.tao2shou.listener.OnQueryUserInfoListener;
import cn.hrlly.tao2shou.utils.DatabaseUtil;

/**
 * User: gengliang
 * Date: 2016-01-31
 * Time: 19:17
 */

public class QueryUserInfoBizImpl implements QueryUserInfoBiz {

    private OnQueryUserInfoListener onQueryUserInfoListener;
    private DatabaseUtil databaseUtil;

    public QueryUserInfoBizImpl(OnQueryUserInfoListener onQueryUserInfoListener,Context context) {
        this.onQueryUserInfoListener = onQueryUserInfoListener;
        this.databaseUtil=new DatabaseUtil(context);
    }

    @Override
    public void queryUserInfoBiz() {
        User user=databaseUtil.selectUserInfo();
        if(user!=null)
            onQueryUserInfoListener.queryUserInfoSucc(user);
        else
            onQueryUserInfoListener.queryUserInfoFail(R.string.user_info_is_null);
    }

    @Override
    public void closeDataBase() {
        databaseUtil.closeDatabase();
    }
}
